/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.hotels;

import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author Liren
 */
public class HotelHelper {
    Session session = null;

    public HotelHelper() {
        this.session = HibernateUtil.getSessionFactory().getCurrentSession();
    }

    public List<Hotel> getHotels(int startID,int endID){
        List<Hotel> hotels = null;
        try{
            org.hibernate.Transaction tx = session.beginTransaction();
            Query q = session.createQuery("from Hotel as hotel where hotel.hotelid between "+startID+" and "+endID);
            hotels = (List<Hotel>)q.list();
        }catch(Exception ex){
            ex.printStackTrace();
        }
        return hotels;
    }
}
